<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page trimDirectiveWhitespaces="true" isELIgnored="false" session="false" %>
<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn"  uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--ctxPath--%>
<c:set var="ctxPath" value="${pageContext.request.contextPath}" />
<%--静态文件目录 --%>
<c:set var="staticPath" value="${ctxPath}/static" />
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>login</title>
    <link rel="stylesheet" href="${staticPath}/fms/css/login.css"><script type="text/javascript" src="${staticPath}/jquery/jquery-2.1.4.min.js"></script>
    <script type="text/javascript" src="${staticPath}/layer/layer.js"></script>
    <script type="text/javascript" src="${staticPath }/assets/js/jquery.form.js" charset="utf-8"></script>
    <style type="text/css">
    	.error-box{
			color:#ff1600;
			font-size:14px;
			margin-bottom:10px;
			margin-left:30px;
		}
    </style>
</head>
<body>
    <div class="header">
        <div class="h-wrapper">
<%--             <img src="${staticPath}/fms/css/images/logo.png" alt="logo"> --%>
            <span class="title_01">XXXX公司</span>
            <span class="title_02">财务管理系统</span>
        </div>
    </div>
    <div class="main-container">
        <div class="login-wrapper">
        <form class="registerform"  action="${ctxPath}/login.do" id="loginform" method="post">
            <div class="userArea area">
                <input type="text"  placeholder="请输入用户名" maxlength="20" id="username" name="username">
                <i class="del"></i>
                <div class="ui-form-explain"></div>
            </div>
            <div class="passArea area">
                <input type="password" placeholder="请输入密码" maxlength="50" name="password" id="password">
                <i class="del"></i>
                <div class="ui-form-explain"></div>
            </div>
            <button id="sub_btn" type="submit">登录</button>
            <br>
            <div style="text-align:center">
                               没有账号？点击 <a id="sub_btn" href="${ctxPath}/register/regist.do">注册</a>
            </div>
            <br>
        	<div class="error-box"></div>
        </form>
        </div>
    </div>
    <div class="footer">
        <p>Copyright © 2018.Company name All rights reserved.</p>
    </div>
</body>
<script>
    $(function(){
        $(".main-container input").on("input",function () {
            var _this = $(this);
            var val = _this.val();
            if(val.length >0){
                _this.siblings(".del").css("display","block");
            }else {
                _this.siblings(".del").css("display","none");
            }
        });
        $(".main-container .del").on("click",function () {
            var _this = $(this);
            _this.siblings("input").val('');
            _this.css("display","none");
        });
    });
  
  //表单提交
  var basePath = "${ctxPath }";
	$('#loginform').submit(function(e) {
		e.preventDefault();
		//判断表单验证是否通过
      $(this).ajaxSubmit(function(data) {
	    	 if(data && (data == "true" || data == true)){
	    		 window.location.href = basePath + '/index.do';
	    	 }else{
	    		 var respdata = JSON.parse(data);
	    		 $(".error-box").text(respdata.msg);
	    	 }        
	    });  
		
	  return false;
	    
	});
	
</script>
</html>
